<template>
	<view class="flex-col page">
		<view class="flex-col flex-1 group_2">
			<!-- <view class="status-title" v-if="status == 0">
				审核中
			</view> -->
			<view class="flex-col">
				<text class="self-start font">请您输入公司名称</text>
				<text class="self-start font">Please enter the company name</text>
				<view>
					<input v-model="gongsi_name" type="text" class="section_2 input mt-15" />
				</view>
			</view>
			<view class="flex-col group_3">
				<text class="self-start font">请您输入姓名</text>
				<text class="self-start font">Please enter your name</text>
				<view>
					<input v-model="name" type="text" class="section_2 input mt-15" />
				</view>
			</view>
			<view class="flex-col group_3">
				<text class="self-start font">请您输入职位</text>
				<text class="self-start font">Please enter your position</text>
				<view>
					<input v-model="zhiwei" type="text" class="section_2 input mt-15" />
				</view>
			</view>
			<view class="flex-col group_4">
				<text class="self-start font">请您输入电话号</text>
				<text class="self-start font">Please enter your phone number</text>
				<view>
					<input v-model="tel" type="text" class="section_2 input mt-15" />
				</view>
			</view>
			<view class="flex-col group_5">
				<text class="self-start font">请您输入感兴趣的产品</text>
				<text class="self-start font">Please enter the product you are interested in</text>
				<view>
					<input v-model="chanpin" type="text" class="section_2 input mt-15" />
				</view>
			</view>
			<view class="bottom flex-row justify-center">
				<view @click="submit" class="flex-col justify-center items-center button text-wrapper"><text class="font text_2">提交</text><text class="font text_2">submit</text>
				</view>
			</view>
			
		</view>
	</view>
</template>

<script>
	import {
		chanpinForm
	} from '@/api/home.js'
	import {
		userInfo
	} from '@/api/user.js'
	export default {
		data() {
			return {
				gongsi_name: '',//公司名称
				name: '',//人员姓名
				zhiwei: '',//人员职位
				tel: '',//电话号
				chanpin: '',//感兴趣的产品
				status: 2,
			}
		},
		onLoad() {
			// this.getInfo()
			
		},
		methods: {
			getInfo(){
				userInfo({
					uid: uni.getStorageSync("uid")
				}).then(res => {
					this.status = res.data.status
					this.gongsi_name = res.data.gongsi_name
					this.name = res.data.name
					this.zhiwei = res.data.zhiwei
					this.tel = res.data.tel
					this.chanpin = res.data.chanpin
				})
			},
			submit(){
				if(this.gongsi_name == ''){
					uni.showToast({
						title: '公司名称不能为空',
						icon: 'none'
					})
					return
				}
				if(this.name == ''){
					uni.showToast({
						title: '人员姓名不能为空',
						icon: 'none'
					})
					return
				}
				if(this.zhiwei == ''){
					uni.showToast({
						title: '人员职位不能为空',
						icon: 'none'
					})
					return
				}
				if(this.tel == ''){
					uni.showToast({
						title: '电话号不能为空',
						icon: 'none'
					})
					return
				}
				const regex = /^1[3456789]\d{9}$/;
				// if(!regex.test(this.tel)){
				// 	uni.showToast({
				// 		title: '电话号格式不正确',
				// 		icon: 'none'
				// 	})
				// 	return
				// }
				if(this.chanpin == ''){
					uni.showToast({
						title: '感兴趣的产品不能为空',
						icon: 'none'
					})
					return
				}
				chanpinForm({
					gongsi_name: this.gongsi_name,//公司名称
					name: this.name,//人员姓名
					zhiwei: this.zhiwei,//人员职位
					tel: this.tel,//电话号
					chanpin: this.chanpin,//感兴趣的产品
					// uid: uni.getStorageSync("uid")
				}).then(res=>{
					if(res.errno == 0){
						uni.showToast({
							title: '提交成功'
						})
						uni.setStorageSync("uid",1)
						setTimeout(()=>{
							uni.redirectTo({
								url: '/pages/index/index'
							})
						},500)
						
						
					}
				})
			}
		}
	}
</script>

<style>
	@import url('../../common/css/common.css');

	.mt-15 {
		margin-top: 30rpx;
	}

	.page {
		background-color: #ffffff;
		width: 100%;
		overflow-y: auto;
		overflow-x: hidden;
		height: 100%;
	}

	.group_2 {
		padding: 53rpx 30rpx 130rpx;
		overflow-y: auto;
	}

	.font {
		font-size: 32rpx;
		font-family: PingFang SC;
		line-height: 31rpx;
		font-weight: 500;
		color: #151515;
	}

	.section_2 {
		align-self: stretch;
		padding-left: 20rpx;
	}

	.input {
		background-color: #f6f7fb;
		border-radius: 16rpx;
		height: 96rpx;
	}

	.group_3 {
		margin-top: 49rpx;
	}

	.group_4 {
		margin-top: 49rpx;
	}

	.group_5 {
		margin-top: 50rpx;
	}
	.bottom {
		width: 100%;
		position: fixed;
		left: 0;
		bottom: 40rpx;
	}

	.button {
		/* margin-top: 491rpx; */
		width: 690rpx;
		height: 88rpx;
		background: #004D9D;
		border-radius: 8rpx;
		line-height: 88rpx;
	}

	/* .text-wrapper {
		padding: 28rpx 0;
		background-color: #004d9d;
		border-radius: 8rpx;
	} */

	.text_2 {
		color: #ffffff;
	}
	.status-title{
		margin-bottom: 20rpx;
		color: #ff5500;
	}
</style>